package com.java01.misc.json;

import org.json.JSONException;
import org.json.JSONObject;

public class StringToJSON {

	public static void main(String[] args) {
		String jsonString = "{\"site\":\"www.java01.com\",\"skill\":[\"java\",\"perl\",\"c++\"],\"age\":20,\"name\":\"atoo\"}";
		try {
			JSONObject json = new JSONObject(jsonString);
			
			System.out.println("name="+json.getString("name"));
			System.out.println("age="+json.getInt("age"));
			System.out.println("site="+json.getString("site"));
			System.out.println("skill="+json.get("skill"));
			
			System.out.println("The data type of skill is "+json.get("skill").getClass().getName());
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
}